
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>新建工作经历信息</title>
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">
    <link rel="stylesheet" href="/css/notice/noticeManagement.css">
    <script src="../../lib/layer/layer.js?20201106"></script>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/common/language.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/ueditor/ueditor.all.js" type="text/javascript" charset="utf-8"></script>

    <%--<script src="../js/jquery/jquery.cookie.js"></script>--%>
    <script src="/lib/jquery.form.min.js"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>

        input{
            float: none;
        }
        .editAndDelete3{
            color: red;
        }
        .bar {
            height: 18px;
            background: green;
        }
        select{
            width: 228px !important;
            padding-left: 10px;
        }
        .newClass{
            float: right;
            width: 90px;
            height: 28px;
            background: url(../../img/file/cabinet01.png) no-repeat;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin: 2% 2% 0 0;
            cursor: pointer;
        }


        .tableMain table tbody td input[type=text]:focus{
            border-color:#ccc;
        }
    </style>
    <script src="/lib/ueditor/UEcontroller.js" type="text/javascript" charset="utf-8"></script>

    <script>

    </script>
</head>
<body>
<div class="navigation">
    <img src="/img/commonTheme/${sessionScope.InterfaceModel}/newsManages2_1.png" alt="">
    <h2 id="title_info">新建工作经历信息</h2>

    <div class="newClass" id="newClass" style="display: block;">
            <span style="margin-left: 30px;">
                <%--<img style="margin-right: 4px;margin-left: -11px;margin-bottom: 2px;" src="../../img/mywork/newbuildworjk.png" alt="">--%>
                返回
            </span>
    </div>
</div>
<div id="pagediv" class="tableMain">
    <%--<form id="ajaxform" action="/Hr/Incentive/addHrIncentive">--%>
    <table>
        <tbody>

        <tr>
            <td class="blue_text" width="20%">
                <p >单位员工：</p>
            </td>
            <td width="80%" style="text-align: left">
                <textarea name="" class="theControlData" readonly="readonly" id="personnel" style="width: 30%;" rows="3"></textarea>
                <a style="margin-left:5px;" href="javascript:;" class="addControls" data-type="3"><fmt:message code="global.lang.add"/></a>
                <a href="javascript:;" style="color: red" class="cleardate"><fmt:message code="global.lang.empty"/></a>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                担任职务：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="postOfJob">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                所在部门：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="workBranch">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                证明人：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="witness">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                开始日期：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="startDate" readonly="readonly" onclick="laydate({format: 'YYYY-MM-DD'})">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                结束日期：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="endDate" readonly="readonly" onclick="laydate({format: 'YYYY-MM-DD'})">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                行业类别：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="mobile">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                工作单位：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="workUnit">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                工作内容：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="workContent">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                离职原因：
            </td>
            <td width="80%" style="text-align: left">
                <input style="width: 228px" type="text" name="reasonForLeaving">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                备注：
            </td>
            <td width="80%" style="text-align: left">
                <textarea name="remark" id="remark" rows="5" style="background: #fff;width: 30%;"></textarea>
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                附件文档：
            </td>
            <td width="80%" class="files" id="files_txt">
            </td>
        </tr>
        <tr>
            <td class="blue_text" width="20%">
                附件上传：
            </td>
            <td width="80%" style="text-align: left">
                <form id="uploadimgform" style="float: left;" target="uploadiframe"  action="/upload?module=INCENTIVE"  method="post" >
                    <input type="file" multiple="multiple" name="file"  id="uploadinputimg"  class="w-icon5" style="position: absolute;opacity: 0;width: 70px;filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0)">
                    <a href="#" id="uploadimg"><img style="margin-right:5px;" src="/img/icon_uplod.png"/><fmt:message code="global.th.fileup" /></a>
                </form>
                <div id="progress" style="width: 200px;float: left;margin-left: 10px;margin-top: 2px;">
                    <div class="bar" style="width: 0%;"></div>
                </div>
                <div class="barText" style="float: left;margin-left: 10px;"></div>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="padding: 5px;">
                主要业绩：
                <div id="word_container" name="keyPerformance">

                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center" class="btnarr">
                <a href="javascript:;" class="savebtn"><fmt:message code="global.lang.save"/></a>
            </td>
        </tr>
        </tbody>
    </table>
    <%--</form>--%>
</div>
<script>
    var type = $.GetRequest().type;
    var userId= decodeURI($.GetRequest().userId);

    var user_id='';
    ue = UE.getEditor('word_container',{elementPathEnabled : false});
    UEimgfuc();
    var inDataId=GetQueryString('dataid');
    var typeHr=GetQueryString('typeHr');
    $(function () {
        if(typeHr == '1'){
            $('#newClass').hide();
        }else{
            $('#newClass').show();
        }
        $('input[name="salaryMonth"]').val(queryTime());

        fileuploadFn('#uploadinputimg',$('#files_txt'));
        //    返回
        $(document).on('click','.newClass',function () {
            if(type!=undefined){
                $(window.parent.document).find('.main').find('iframe').prop('src','/hr/manage/bonpenManage?type=1&userId='+userId)
            }else{
                $(window.parent.document).find('.main').find('iframe').prop('src','/hr/manage/bonpenManage')
            }

        })
        //附件删除
        $('#files_txt').on('click','.deImgs',function(){
            var data=$(this).parents('.dech').attr('deUrl');
            var dome=$(this).parents('.dech');
            deleteChatment(data,dome);
        })

        $('.addControls').click(function () {
            user_id='personnel';
            $.popWindow("/common/selectUser?0");
        })
        $('.cleardate').click(function () {
            $('#personnel').attr('username','');
            $('#personnel').attr('dataid','');
            $('#personnel').attr('user_id','');
            $('#personnel').attr('userprivname','');
            $('#personnel').val('');
        })

        if(inDataId != null && inDataId != undefined){
            ue.ready(function(){
                $(document).attr('title','编辑工作经历信息');
                $('#title_info').html('编辑工作经历信息')
                $.ajax({
                    type:'get',
                    url:'/hr/manage/selectById',
                    dataType:'json',
                    data:{
                        wExperienceId:inDataId
                    },
                    success:function (res) {
                        var datas=res.object;
                        $('#personnel').val(datas.userName+',');
                        $('#personnel').attr('user_id',datas.staffName+',');
                        $('input[name="postOfJob"]').val(datas.postOfJob)
                        $('input[name="workBranch"]').val(datas.workBranch)
                        $('input[name="witness"]').val(datas.witness)
                        $('input[name="startDate"]').val(datas.startDate)
                        $('input[name="endDate"]').val(datas.endDate)
                        $('input[name="mobile"]').val(datas.mobile)
                        $('input[name="workUnit"]').val(datas.workUnit)
                        $('input[name="workContent"]').val(datas.workContent)
                        $('input[name="reasonForLeaving"]').val(datas.reasonForLeaving)
                        $('#remark').val(datas.remark);
                        ue.setContent(datas.keyPerformance);

                        var str='';
                        var arrList=datas.attachmentList;
                        if(arrList.length>0){
                            for(var i=0;i<arrList.length;i++){
                                str+='<div class="dech" deUrl="'+encodeURI(arrList[i].attUrl)+'">' +
                                    '<a href="<%=basePath %>download?'+encodeURI(arrList[i].attUrl)+'" NAME="'+arrList[i].attachName+'*" style="text-decoration:none;">' +
                                    '<img style="margin-right:10px;" src="/img/attachment_icon.png"/>'+arrList[i].attachName+'</a>' +
                                    '<img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/>' +
                                    '<input type="hidden" class="inHidden" value="'+arrList[i].aid+'@'+arrList[i].ym+'_'+arrList[i].attachId+',">' +
                                    '</div>';
                            }
                            $('#files_txt').append(str);
                        }

                    }
                })
            })

        }else{
            if(type!=undefined){
                $('#personnel').val(parent.userName+',');
                $('#personnel').attr('user_id',userId+',');
                $('#personnel').attr('dataId',userId+',');
                $('#personnel').attr('userName',parent.userName+',');
            }
        }

        $('.savebtn').click(function () {
            var html = ue.getContent();
            var attachId='';
            var attachName='';
            for(var i=0;i<$('#files_txt .inHidden').length;i++){
                attachId+=$('#files_txt .inHidden').eq(i).val();
                attachName+=$('#files_txt a').eq(i).attr('NAME');
            }
            if(inDataId != '' && inDataId != undefined){
                $.ajax({
                    type:'get',
                    url:'/hr/manage/updateHrWorkExperience',
                    dataType:'json',
                    data:{
                        staffName:$('#personnel').attr('user_id'),
                        postOfJob:$('input[name="postOfJob"]').val(),
                        workBranch:$('input[name="workBranch"]').val(),
                        witness:$('input[name="witness"]').val(),
                        startDate:$('input[name="startDate"]').val(),
                        endDate:$('input[name="endDate"]').val(),
                        mobile:$('input[name="mobile"]').val(),
                        workUnit:$('input[name="workUnit"]').val(),
                        workContent:$('input[name="workContent"]').val(),
                        reasonForLeaving:$('input[name="reasonForLeaving"]').val(),
                        remark:$('#remark').val(),
                        attachmentId:attachId,
                        attachmentName:attachName,
                        keyPerformance:html,
                        wExperienceId:inDataId
                    },
                    success:function (res) {
                        if(res.flag){
                            $.layerMsg({content: '修改成功！', icon: 1}, function () {
                                if(typeHr == '1'){
                                    window.close();
                                    window.opener.gongzuoData();
                                }else {
                                    if(type!=undefined){
                                        parent.$('[name="notices"]').attr('src','/hr/manage/bonpenManage?type=1&userId='+userId)
                                    }else{
                                        parent.$('[name="notices"]').attr('src','/hr/manage/bonpenManage')
                                        parent.$('.head-top ul li').removeClass('active')
                                        $((parent.$('.head-top ul li'))[0]).addClass('active')
                                    }

                                }
                            });
                        }else {
                            $.layerMsg({content:'修改失败！', icon: 2});
                        }
                    }
                })
            }else {
                $.ajax({
                    type:'post',
                    url:'/hr/manage/addHrWorkExperience',
                    dataType:'json',
                    data:{
                        staffName:$('#personnel').attr('user_id'),
                        postOfJob:$('input[name="postOfJob"]').val(),
                        workBranch:$('input[name="workBranch"]').val(),
                        witness:$('input[name="witness"]').val(),
                        startDate:$('input[name="startDate"]').val(),
                        endDate:$('input[name="endDate"]').val(),
                        mobile:$('input[name="mobile"]').val(),
                        workUnit:$('input[name="workUnit"]').val(),
                        workContent:$('input[name="workContent"]').val(),
                        reasonForLeaving:$('input[name="reasonForLeaving"]').val(),
                        remark:$('#remark').val(),
                        attachmentId:attachId,
                        attachmentName:attachName,
                        keyPerformance:html
                    },
                    success:function (res) {
                        if(res.flag){
                            $.layerMsg({content: '保存成功！', icon: 1}, function () {
                                if(typeHr == '1'){
                                    window.close();
                                    window.opener.gongzuoData();
                                }else {
                                    if(type!=undefined){
                                        parent.$('[name="notices"]').attr('src','/hr/manage/bonpenManage?type=1&userId='+userId)
                                    }else{
                                        parent.$('[name="notices"]').attr('src','/hr/manage/bonpenManage')
                                        parent.$('.head-top ul li').removeClass('active')
                                        $((parent.$('.head-top ul li'))[0]).addClass('active')
                                    }

                                }
                            });
                        }else {
                            $.layerMsg({content:'保存失败！', icon: 2});
                        }
                    }
                })
            }
        })

    })

    //删除附件
    function deleteChatment(data,element){

        layer.confirm('<fmt:message code="workflow.th.que" />？', {
            btn: ['<fmt:message code="global.lang.ok" />','<fmt:message code="depatement.th.quxiao" />'], //按钮
            title:"<fmt:message code="notice.th.DeleteAttachment" />"
        }, function(){
            //确定删除，调接口
            $.ajax({
                type:'get',
                url:'/delete',
                dataType:'json',
                data:data,
                success:function(res){

                    if(res.flag == true){
                        layer.msg('<fmt:message code="workflow.th.delsucess" />', { icon:6});
                        element.remove();
                    }else{
                        layer.msg('<fmt:message code="lang.th.deleSucess" />', { icon:6});
                    }
                }
            });

        }, function(){
            layer.closeAll();
        });
    }

    function queryTime(){
        function p(s) {
            return s < 10 ? '0' + s: s;
        }
        var myDate = new Date();
        //获取当前年
        var year=myDate.getFullYear();
        //获取当前月
        var month=myDate.getMonth()+1;
        //获取当前日
        var date=myDate.getDate();
        var h=myDate.getHours();       //获取当前小时数(0-23)
        var m=myDate.getMinutes();     //获取当前分钟数(0-59)
        var s=myDate.getSeconds();
//        var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);
        var now=year+'-'+p(month);
//        if(type==undefined){
//            return now;
//        }else {
//            return year+'-'+p(month)+"-"+p(date)
//        }
        return now;


    }

    // 用正则表达式获取地址栏参数
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);

        if(r!=null) {
            return  unescape(r[2]);
        } else {
            return null;
        }
    }

</script>
</body>
</html>